import synonyms
import os


def zhenghuo():
    with open ("YY丁真合集.txt","r",encoding="utf-8") as reader_file :
        word_list = reader_file.read().split("\n")[1:]

    if os.path.exists("构造语句合集.txt"):
        os.remove("构造语句合集.txt")
    for word in word_list :
        word = word[0:2]
        # print(word)
        word_list,vetor_list = synonyms.nearby(word)
        if len(word_list) > 1 :
            same_word = max(word_list[1:], key=len, default='')
            print(word,same_word)

            with open ("构造语句合集.txt","a",encoding="utf-8") as writer_file :
                writer_file.write(f"\n{word}丁真,鉴定为{same_word}")





        # break

if __name__ == "__main__" :
    zhenghuo()